<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>天气案例</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <h2>今天天气很{{info}}</h2>

        <!-- 绑定的click事件后可以写简单的语句  但如果有多条语句用分号隔开，此时还是建议写method配置方法了 -->
        <!-- <button @click="isHot=!isHot">点击切换天气</button> -->
        <button @click="changeW">点击切换天气</button>
    </div>
    <script>
        Vue.config.productionTip = false
        var vm = new Vue({
            el: '#root',
            data: {
                isHot: true
            },
            computed: {
                info() {
                    return this.isHot ? '炎热' : '凉爽';
                }
            },
            methods: {
                changeW() {
                    this.isHot = !this.isHot
                }
            }
        });
    </script>
</body>

</html>